<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title> 我的收货地址 - LooPo-乐铺 </title>
<?php include VIEWS.'header.html'?>

<style type="text/css">
.tt{
    width: 96%;
    padding: 0;
}

.tt td{
    border-bottom: 1px dotted #CCCCCC;
    font-size: 12px;
}

.ti {
    line-height: 150%;
}
</style>

<script type="text/javascript">
<!--
var aa = ajaxStart();
var timer = null;

function paddress_change() {
    try{
        $('submit').disabled = true;
        $('submita').disabled = true;
    } catch(e) {}
    var f = $('updateform');
    aa.call('/myAddress.php', 'ajaxuserAddressPrimarySet', paddress_changed, $('updateform').serialize());
    return false;
}

function paddress_changed(result) {
    var i;
    var d = $('updatemsg');
    try {
        var stat = result.result[0].data;
        if (stat==1) i = '默认收货地址已更新';
        if (stat==2) i = '<font color=FFFF66>更新失败</font>，请检查您的选择后再试';
    } catch(e) {
        i = '服务器错误，请稍候再试';
        d.style.backgroundColor= '#FF6600';
        d.style.color = '#FFF';
    }

    try{$('err4').hide()} catch(e) {}
    try{
        $('submit').disabled = false;
        $('submita').disabled = false;
    } catch(e) {}
    d.innerHTML = '&nbsp;&nbsp;&nbsp;' + i + '……';
    $('updatemsg').show();
    new Effect.Round('div', 'updatemsg');
    if (timer) window.clearTimeout(timer);
    timer = setTimeout( "$('updatemsg').style.display='none';", 10000);
}
//-->
</script>

</head>

<body>

<?php include VIEWS.'topbar.html'?>

<div id="content">

    <?php include VIEWS.'leftnav.html'?>

    <div id="right">

    <h1>我的收货地址</h1>


<h3 style="margin-bottom:5px"><img src="/images/icon_arrow_down.gif" />现有收货地址</h3>
<hr size="1" />
<div class="updatemsg" id="updatemsg" style="font-weight:bold;background-color:#DDF63E;font-size:12px;width:90%;display:none;">&nbsp;</div>
<?php if($code['userAddressUpdate']&4):?><div id="err4" class="errbox roundNormal" style="width:90%">&nbsp;&nbsp;&nbsp;默认收货地址不能被删除</div><?php endif?>

<br />
<?php if(!count($list)):?>
<div class="errbox roundNormal" style="width:90%">&nbsp;&nbsp;&nbsp;您目前没有设置任何收货地址</div>
<?php else:?>
<form action="/myAddress.php" method="post" id="updateform" onsubmit="return paddress_change()">
<?php echo round_table('96%', ($data['archive'] ? 'CCCCCC' : '3366CC'), 'white', 3, 3, 'top')?>
<table class="tt" cellspacing="0">
<tr class="ti" style="font-weight:bold;background-color:#3366CC;color:#FFF"><td nowrap="nowrap">&nbsp;主地址</td><td nowrap="nowrap">联系人</td><td>电话</td><td>地址及邮编</td><td>&nbsp;</td></tr>
<?php foreach($list as $v):?>
<tr class="ti"><td><input type="radio" name="paddr" value="<?php echo $v['id']?>"<?php if($v['paddr']):?> checked<?php endif?> /></td><td class="px12"> <?php echo $v['linkman']?> </td><td class="px11"> <?php echo $v['tel']?> </td><td class="px12"> <?php echo $v['address']?><span class="px11">(<?php echo $v['zipcode']?>)</span> </td><td class="px12" nowrap="nowrap">[<a onclick="javascript:return confirm('确认要删除该收货地址吗?')" href="/myAddress.php/remove/<?php echo $v['id']?>" title="删除该地址">删除</a>]&nbsp;</td></tr>
<?php endforeach?>
</table>
<br />
<input id="submit" type="submit" value="设为默认收货地址" class="bluebtn" />
</form>
<?php endif?>

<br /><br />
<h3><img id="rightarrow" src="/images/icon_arrow_right.gif" /><img id="downarrow" src="/images/icon_arrow_down.gif" style="display:none" /><a href="#" onclick="javascript:$('newaddress','rightarrow','downarrow').invoke('toggle');this.blur();$('linkman').focus()">添加新的收货地址</a></h3>
<?php if($code['userAddressUpdate']&8):?><div class="errbox roundNormal" style="width:90%">&nbsp;&nbsp;&nbsp;请填完整您的收货信息后再提交</div><br clear="all" /><?php endif?>

<div id="newaddress" style="display:none">
<form action="/myAddress.php" method="post">
<table width="100%">
<tr><td width="10%">收货人</td><td><input class="input1" id="linkman" type="text" name="linkman" maxlength="30" size="10" value="<?php echo $data['linkman']?>" /></td></tr>
<tr><td>电话</td><td><input class="input1" type="text" name="tel" maxlength="20" size="12" value="<?php echo $data['tel']?>" /></td></tr>
<tr><td>地址</td><td><input class="input2" type="text" name="address" maxlength="100" size="46" value="<?php echo $data['address']?>" /></td></tr>
<tr><td>邮编</td><td><input class="input0" type="text" name="zipcode" maxlength="6" size="7" value="<?php echo $data['zipcode']?>" /></td></tr>
</table>
<br />
<input id="submita" type="submit" name="aaddr" value="添加为收货地址" class="bluebtn" />
</form>
</div>

<?php if($code['userAddressUpdate']&8):?><script type="text/javascript">$('newaddress','rightarrow','downarrow').invoke('toggle');</script><?php endif?>

    </div>
</div>

<?php include VIEWS.'copyright.html'?>

</body>
</html>
